package com.yangfei.domain;

public class ReferencePkValue2 {
     
    public static void main(String[] args) { 
        ReferencePkValue2 t = new ReferencePkValue2(); 
        int a=99; 
        t.test1(a);//这里传递的参数a就是按值传递 
        System.out.println(a);
         
        MyObj obj=new MyObj();
        System.out.println("一"+obj);
        t.test2(obj);//这里传递的参数obj就是引用传递
        System.out.println(obj.b);
        System.out.println("三"+obj);
    } 
     
    public void test1(int a){ 
        a=a++;
        System.out.println(a);
        } 
     
    public void test2(MyObj m){
        System.out.println("新"+m);
        MyObj n = new MyObj();
        m=n;
        System.out.println("二"+m);
        m.b = 100;
        System.out.println(m.b);
       /* m.b=100;
        System.out.println(m.b);*/
        }
}
class MyObj{
    public int b=66;
}